<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title>过滤敏感字符</title>
	<script type="text/javascript">

        window.onload = function(){
        	var oTxt1 = document.getElementById('txt1');
        	var oBtn = document.getElementById('btn1');
        	var oTxt2 = document.getElementById('txt2');

        	oBtn.onclick = function(){
        		//正则规则
        		var re = /北京|东莞|百度|淘宝/g; //g:global   找到所有
        		//把正则匹配到的敏感字符替换为***
        		oTxt2.value = oTxt1.value.replace(re,'***');
        	};
        };

	</script>
</head>
<body>
    
    <textarea id="txt1" cols="30" rows="10"></textarea><br/>
    <input type="button" id="btn1" value="过滤"><br/>
    <textarea id="txt2" cols="30" rows="10"></textarea>
	
</body>
</html>